home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Unix / go4gw1.1 / g2areacode < prev    next >
Encoding:
Text File  |  1993-04-30  |  1.1 KB  |  60 lines

  1. #!/usr/local/bin/perl
  2.  
  3. #----------------------------------------------------------------------
  4. # variables you should change:
  5.  
  6. $areacode_prog  = "/home/ashpool/go4gw/areacode";
  7.  
  8. #----------------------------------------------------------------------
  9.  
  10. sub areacode_main {
  11.     local($_) = @_;
  12.     
  13.     if (/^$/) {
  14.     &Greply("0List of all Area Codes\t$Ggw &.\t$Ghost\t$Gport");
  15.     &Greply("7Find a specific Area Code\t$Ggw\t$Ghost\t$Gport");
  16.     &Greply(".");
  17.     exit(0);
  18.     }
  19.     
  20.     $Afile = 1 if (/^&/);
  21.     s/^&//;
  22.  
  23.     #filter out everything but letters and numbers
  24.     s/[^A-Za-z0-9 ]//g;
  25.  
  26.     $searchstr = $_;
  27.     open(Areaprog, "$areacode_prog $_|");
  28.     
  29.     while(<Areaprog>) {
  30.     s/\n//;
  31.     s/\r//;
  32.         push(@lines,$_);
  33.     }
  34.     
  35.     #
  36.     # Always return the output of the search first
  37.     #
  38.     if ($Afile) {
  39.     # reply with a file...
  40.     foreach (@lines) {
  41.         &Greply($_);
  42.         }
  43.     } else {
  44.     &Greply("0Search Results in a file\t$Ggw & $searchstr\t$Ghost\t$Gport");
  45.     foreach (@lines) {
  46.         m/(\d+)/;
  47.         &Greply("0$_\t$Ggw & $1\t$Ghost\t$Gport");
  48.     }
  49.     }
  50.  
  51.  
  52.     &Greply(".");
  53.     exit(0);
  54. }
  55.  
  56.  
  57.  
  58.  
  59. 1; # for require
  60.